﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;

namespace Djs.Neuronic
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            // RunTest();
            RunMain();
        }
        private static void RunTest()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // Application.Run(new UI.TestInteractiveForm());
            Application.Run(new UI.DialogForm());
        }
        private static void RunMain()
        {
            using (Djs.Neuronic.Brain.CreatorCls creator = Brain.CreatorCls.Create())
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Rectangle? bounds = null;
                while (true)
                {
                    try
                    {
                        using (UI.MainForm mainForm = new UI.MainForm())
                        {
                            if (bounds.HasValue)
                                mainForm.Bounds = bounds.Value;
                            mainForm.Creator = creator;
                            Application.Run(mainForm);
                            bounds = mainForm.Bounds;
                        }
                    }
                    catch (Exception)
                    { }
                    if (creator.IsCompleted)
                        break;
                }
            }
        }
    }
}
